#include "Metgine/Input/MouseManager.hpp"

namespace Metgine
{
namespace Input
{

void MouseManager::Update()
{
    for (int i = 0; i < sf::Mouse::ButtonCount; i++)
    {
        m_pressedButtons[i] = m_mainInput.IsMouseButtonDown((sf::Mouse::Button)i);
        if (m_pressedButtons[i])
            m_lastPressed = (sf::Mouse::Button)i;
    }
}

bool MouseManager::IsAnyButtonDown()
{
    for(int i = 0; i < sf::Mouse::ButtonCount; i++)
    {
        if (IsButtonDown((sf::Mouse::Button)i))
            return true;
    }

    return false;
}

bool MouseManager::IsButtonDown(sf::Mouse::Button Button)
{
    return m_pressedButtons[(int)Button];
}

bool MouseManager::IsButtonUp(sf::Mouse::Button Button)
{
    return !m_pressedButtons[(int)Button];
}

bool MouseManager::IsButtonReleased(sf::Mouse::Button Button)
{
    return (!m_mainInput.IsMouseButtonDown(Button) && m_pressedButtons[(int)Button]);
}

int MouseManager::MouseX()
{
    return m_mainInput.GetMouseX();
}

int MouseManager::MouseY()
{
    return m_mainInput.GetMouseY();
}

sf::Mouse::Button MouseManager::GetLastPressed()
{
    return m_lastPressed;
}

}; // Input
}; // Metgine

